//
//  SJZCouponCell.m
//  SJZBusiness
//
//  Created by 位立志 on 2018/5/7.
//  Copyright © 2018年 bwton. All rights reserved.
//

#import "SJZCouponCell.h"

@interface SJZCouponCell()

@property (strong, nonatomic) IBOutlet UILabel *couponNumLabel;

@property (strong, nonatomic) IBOutlet UILabel *couponTimeLabel;

@property (strong, nonatomic) IBOutlet UILabel *couponNameLabel;

@end

@implementation SJZCouponCell

+ (instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    
    static NSString *cellID = @"SJZCouponCellID";
    SJZCouponCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"SJZCouponCell" owner:nil options:nil] firstObject];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
    }
    
    if (indexPath.row%2 != 0) {
        cell.backgroundColor = kRGBA(244, 244, 244, 1);
    }else{
        cell.backgroundColor = [UIColor whiteColor];
    }
    
    
    return cell;
}

- (void)awakeFromNib {
    [super awakeFromNib];

    [self addLeftRightLayer];

    self.couponNumLabel.adjustsFontSizeToFitWidth = YES;
    self.couponTimeLabel.adjustsFontSizeToFitWidth = YES;
//    self.couponNameLabel.adjustsFontSizeToFitWidth = YES;
}

- (void)addLeftRightLayer{
    
    //左边框
    CALayer *leftLayer = [CALayer layer];
    leftLayer.backgroundColor = kRGBA(211, 211, 211, 211).CGColor;
    leftLayer.frame = CGRectMake(kScreenWidth/3, 0, 1, 40);
    [self.layer addSublayer:leftLayer];
    //右边框
    CALayer *rightLayer = [CALayer layer];
    rightLayer.backgroundColor = kRGBA(211, 211, 211, 211).CGColor;
    rightLayer.frame = CGRectMake(kScreenWidth/3*2,0,1,40);
    [self.layer addSublayer:rightLayer];
    
}

- (void)setCouponModel:(SJZCouponModel *)couponModel{
    
    _couponModel = couponModel;
    self.couponNameLabel.text = couponModel.voucherName;
    self.couponTimeLabel.text = couponModel.consumeTime;
    self.couponNumLabel.text = couponModel.voucherCode;
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
